*Arduino Basic-How to learn Arduino?
*Controlling stepper motors with arduino (group task)
Arduino output
*Definition of open source hardware
*Arduino basic control board
A stepper motor, also known as step motor or stepping motor, is an electrical
motor that rotates in a series of small angular steps, instead of
continuously. Stepper motors are a type of digital actuator. Like other
electromagnetic actuators, they convert electric energy
into mechanical position can be commanded to move and hold at one of these
steps without any position sensor for feedback (an open-loop controller), as
long as the motor is correctly sized to the application in respect
to torque and speed.
Stepper motor - Wikipedia
*The final code is here
1.Arduino Nano board
2.SG90 Servo
*Component
*processing and arduino linkage
In the processing page, one black ball drops down every two seconds.If
three balls fall in total, the ball stops falling for five seconds.In
addition, the blade of the steering engine controlled by arduino is
rotated 180 degrees to the right for two seconds, and then rotated 180
degrees to the left to return to the original position
*Click on the red box
*Tinkercad-DC motor
#include <Servo.h>
Servo myservo; // 创建舵机对象
int servoPin = 9; // 舵机连接的脚位
void setup() {
myservo.attach(servoPin); // 将舵机绑定到指定脚位
Serial.begin(9600); // 开始串行通信,波特率9600
}
void loop() {
if (Serial.available() > 0) {
char inChar = (char)Serial.read(); // 读取串行输入的字符
if (inChar == 'R') { // 如果接收字符是'R'
myservo.write(180); // 舵机旋转到180度
delay(2000); // 暂停两秒钟
myservo.write(0); // 返回到0度
}
}
}
https://www.tinkercad.com
*Click on the red box, click on Getting Started with arduino, click on
Servoand click on Start Simulation.
*Click on the red box,Briefly describe the personal&prompt, add some
plug-ins only but not limited to (Code Interpreter&Data Analysis),also
but not necessary, modify the Model Configuration in the upper left
corner.
*How to realise?
*Register and Login Coze
https://www.coze.com
*Register and Login Tinkercad
*Ask Coze for
*How to connect processing and arduino?
*Please help me to write a code on processing to make the black ball drop
every 1 second on the right side of the white canvas of 1920*1080
*If you want to change the position of the ball to the center of the
screen, which part of the code should you change?
*Can you help me write a program on the arduino that connects to the
processing and has the ability to control the servo to turn 180 degrees
to the right when the three black balls fall off the canvas?
*Modify the PROCESSING program and the arduino program and write it out
completely to be able to connect with the arduino program
mentioned above, so that the black ball drops every 1 second on the right
side of the white canvas of 1920*1080,and there are
only three black balls, and when all of them drop out of the canvas, then
the servo will be controlled to rotate to the right by 180 degrees.
*Modify the processing program and arduino program and write it out
completely, in the processing, let the black ball in the 1920 * 1080 white
canvas on the right side of the drop every 1 second, there are and only
three black ball, when the ball all fall out of the canvas, then use
the arduino to control the servo to the right 180 degrees!
*Keep the connection with arduino, let the black ball drop every 1 second
on the right side of the white canvas of 1920*1080 in the processing,
modify the processing and arduino code above as follows:
1.the height of each ball falling in the processing is kept equal
2.When three balls fall out of the canvas in the processing, control the
servo in the arduino to rotate 180 degrees to the right,
and control the servo to rotate 180 degrees to the left after a delay of
two seconds.
3.processing in the cumulative number of ball drop to meet the number of
3, then return to the number of 0, and control the ball to stop falling,
in 5 seconds to restart the fall
*How to change the falling speed of the ball
*How to change the ball to drop every two seconds?
*By asking coze these questions, you will understand how to make a small
sample of the interaction between arduino and processing linkage
*How to realise?
2. Install Arduino IDE
Download and install the Arduino IDE from the official Arduino website.
Connect the Arduino board (e.g. Arduino Uno) to the computer.
3. Basic programming and electronics knowledge
1.Basic Programming:
Familiarize yourself with the Arduino IDE interface.
Understand basic C/C++ syntax, such as variables, data types, loops, and
conditional statements.
2.Basic Electronics:
Learn how basic electronic components, such as resistors, capacitors,
diodes, and LEDs, work.
Understand how to connect circuits, such as using breadboards and jumper
wires.
4. Practice the Arduino project:
Open the Arduino IDE and connect the Arduino board to your computer.
Write code in Arduino IDE (specific examples below).
5. Learning resources
Official website: Arduino.cc
Tutorial website: Arduino Project Hub
Books:
Getting Started with Arduino book series
Arduino Projects for Dummies
Online Courses:
Coursera, Udemy, edX have many courses on Arduino.
6. Extension Projects
With some extension projects, you can go deeper into the application of
Arduino:
Sensor project: temperature sensor, ultrasonic sensor, light sensor, etc.
Display project: use LCD display to show information.
Wireless communication: use Bluetooth or WiFi module.
Robotics projects: making simple robots and learning about movement
control, obstacle avoidance, etc.
7. Join the Arduino community
Joining the open source community can help you get more resources, solve
problems and share your projects:
Arduino Forum
Open source projects on GitHub
Arduino groups on various social media outlets
*Common application boards for arduino
Arduino infrared remote control module:Includes IR receiver and remote
control.When you press a button on an infrared remote control, it emits
a specific infrared signal. This signal is received by the infrared
receiver and converted into an electrical signal, which is then read
and interpreted by the Arduino board. The Arduino board can perform
specific tasks based on this signal, such as controlling an LED light
switch.
Arduino's infrared remote control module can be used in a variety of
projects, including robots, home automation systems, wirelessly
controlled toys, and more. You can program the Arduino to respond to
any button on the infrared remote control to implement a variety of
functions.
LED modules usually consist of one or more LED lights and some other
electronic components (such as resistors). An LED (Light Emitting Diode) is
a semiconductor device that emits light. When current passes through an LED,
it emits light.
In addition to the common single-color LED modules, there are also RGB LED
modules. Each LED in the RGB LED module contains three colors of red, green,
and blue LEDs. By adjusting the brightness of these three colors, various
colors of light can be mixed.
LED modules can be used in a variety of Arduino projects, including
displaying status, indicators, backlights, visual effects, and more. For
example, you can use the LED module to create a traffic light, a colored
light effect, or use it to display the working status of your Arduino
project.
import processing.serial.*;
Serial myPort; // 所使用的串行端口
ArrayList<Ball> balls; // 存储小球的列表
int lastTime; // 上一个小球添加的时间
int ballCount; // 记录已掉落小球的数量
void setup() {
size(1920, 1080); // 设定画布大小
balls = new ArrayList<Ball>(); // 初始化小球列表
println(Serial.list()); // 打印可用的串行端口列表
myPort = new Serial(this, Serial.list()[0], 9600); // 打开第一个串行端口
lastTime = millis(); // 记录初始化时间
}
void draw() {
background(255); // 设置背景为白色
if (millis() - lastTime >= 2000) { // 检查是否过去了2秒钟
lastTime = millis(); // 重置计时器
if (ballCount < 3) { // 判断是否已经有三个小球
Ball newBall = new Ball(width - 400, 50); // 在屏幕的右侧侧边生成新的小球
balls.add(newBall);
}
// 清除已经落出画布的小球,并统计数量
for (int i = balls.size() - 1; i >= 0; i--) {
if (balls.get(i).y > height) {
balls.remove(i);
ballCount++;
}
}
if (ballCount >= 3) { // 当有三个小球掉落时
myPort.write('R'); // 发送字符'R'至Arduino
ballCount = 0; // 重置小球计数
delay(5000); // 暂停发送新小球的生成,等待5秒后再次开始
lastTime = millis(); // 重置时间以开始新一轮的小球生成
}
}
// 更新并显示在画布中的小球
for (int i = 0; i < balls.size(); i++) {
Ball ball = balls.get(i);
ball.update();
ball.display();
}
}
class Ball {
float x, y;
float speedY = 10; // 小球下落速度
float diameter = 50; // 小球直径
Ball(float tempX, float tempY) {
x = tempX;
y = tempY;
}
void update() {
y += speedY; // 根据速度更新小球位置
}
void display() {
fill(0); // 小球颜色设置为黑色
ellipse(x, y, diameter, diameter); // 绘制小球
}
}
A stepper motor is an electromechanical device that converts an electrical
pulse signal into an angular or linear displacement.
It rotates in discrete steps, one step for each pulse signal received, hence
the name “stepper” motor.
Characteristics of stepper motors:
Precise Positioning and Speed Control: Because stepper motors rotate in
discrete steps, very precise positioning and speed control can be achieved.
No Feedback Mechanisms Required: Stepper motors can often achieve precise
positioning at low loads without feedback mechanisms such as encoders,
which simplifies the design of the control system.
High Holding Torque: Stepper motors can hold their current position even
during a power failure, making them suitable for applications where holding
force is required.
Fast Response: Stepper motors can be started, stopped and reversed quickly,
making them ideal for applications that require fast positioning.
Types of Stepper Motors:
There are three main types of stepper motors:
Permanent Magnet Stepper Motors: Simple construction and lower cost, but
with lower torque output.
Reactive stepper motors: Higher torque output, but more complex control
circuits.
Hybrid stepper motors: Combine the advantages of permanent magnet and
reactive stepper motors, with higher stepping accuracy and torque output.
Stepper motor applications.
Industrial automation: used to control the movement of robots, positioning
of conveyor belts, opening and closing of valves, etc.
Computer peripherals: e.g. in printers, scanners, plotters to control the
movement of paper and printheads.
Medical equipment: e.g. in medical imaging equipment, drug delivery systems
for precise positioning and control.
Controlling stepper motors.
Controlling a stepper motor requires the use of a specialized driver that
receives pulses from a controller and converts them into signals that
control the
current in the stepper motor's windings to drive the motor.
Comparison of stepper motors with other types of motors.
Compared to DC motors, stepper motors offer higher positioning accuracy, but
their speed and torque outputs are relatively low. Compared to servo motors,
stepper motors are cheaper and simpler to control, but servo motors are a
better choice where high accuracy and high dynamic response are required.
Summarize.
Stepper motors are used in a wide variety of applications due to their high
accuracy, ease of control and lack of need for feedback mechanisms.
Understanding the different types, characteristics and applications of
stepper motors can help you make a more informed decision when selecting a
motor.
*Detail